
# https://video.pearvideo.com/mp4/adshort/20210827/1630294127633-15755349_adpkg-ad_hd.mp4
# https://video.pearvideo.com/mp4/adshort/20210827/cont-1740134-15755349_adpkg-ad_hd.mp4
import requests

url = "https://www.pearvideo.com/video_1740134"
cont_id = url.split('_')[1]

headers =   {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36',
            'Referer': 'https://www.pearvideo.com/video_1740134'#防盗链
            }
url2 = f"https://www.pearvideo.com/videoStatus.jsp?contId={cont_id}&mrd=0.7284372037871256"
resp = requests.get(url2,headers = headers)


src_url = resp.json()['videoInfo']['videos']['srcUrl']
systemTime = resp.json()['systemTime']

print(src_url)

real_video_url = src_url.replace(systemTime,f'cont-{cont_id}')

print(real_video_url)

with open('./img/video.mp4',mode='wb') as f:
    f.write(requests.get(real_video_url).content)

print('over')

resp.close()

pass